package cn.edu.njust.strategy;

import cn.edu.njust.server.Stat;

import java.util.List;

public class LeastBacklogStrategy implements StatelessStrategy {
    @Override
    public int next(List<Stat> stats, List<Integer> weights) {
        int minBacklog = stats.get(0).getBacklog();
        int minIndex = 0;

        Stat stat = null;
        for (int i = 1; i < stats.size(); i++) {
            stat = stats.get(i);
            if (minBacklog > stat.getBacklog()) {
                minBacklog = stat.getBacklog();
                minIndex = i;
            }
        }
        return minIndex;
    }
}
